import request from '@/utils/request'
import { getToken } from '@/utils/auth' // get token from cookie
var token=getToken();
//登录
export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    headers:{'Content-Type':'application/json'},
    data
  })
}
//获取手机验证码
export function getCode(phoneNumber) {
  return request({
    url: '/user/code/'+phoneNumber,
    method: 'get',
    headers:{'Content-Type':'application/json'},
  })
}
//校验手机验证码
export function verifyCode(data) {
  return request({
    url: '/user/verifyCode',
    method: 'post',
    data
  })
}

//修改密码
export function updateUser(data) {
  return request({
    url: '/user/update/password',
    method: 'post',
    data
  })
}
//用户信息
export function getInfo() {
  return request({
    url: '/roleMenu/getUserMenu',
    method: 'post',
    params: { token }
  })
}
// 用户所属部门
export function getByDeptId(id) {
  return request({
    url: '/user/getByDeptId/'+id,
    method: 'get',
    headers:{'Content-Type':'application/json'},
  })
}
//用户添加
export function addto(formData) {
  let newData=JSON.stringify(formData);
  return request({
    url: '/user/add',
    method: 'post',
    headers:{'Content-Type':'application/json'},
    data:newData
  })
}
//用户详情

export function getUserDetail(id) {
  return request({
    url: '/user/detail/'+id,
    method: 'get',
  })
}




//退出登录
export function logout() {
  return request({
    url: '/platform/user/logout',
    method: 'post',
  })
}
//用户列表
export function userList(searchData,pageData) {
  let newData=JSON.stringify(searchData);
  return request({
    url: '/platform/user/page/'+pageData.pageNo+'/'+pageData.pageSize,
    method: 'post',
    headers:{'Content-Type':'application/json'},
    data:newData
  })
}
//用户修改
export function update(formData) {
  let newData=JSON.stringify(formData);
  return request({
    url: '/platform/user/update',
    method: 'post',
    headers:{'Content-Type':'application/json'},
    data:newData
  })
}



//用户删除
export function dele(userId) {
  return request({
    url: '/platform/user/delete/'+userId,
    method: 'post',
    headers:{'Content-Type':'application/json'},
  })
}
export function exportExcel(formData) {
  let newData=JSON.stringify(formData);
  return request({
    url: '/platform/user/exportExcel',
    method: 'post',
    responseType:'blob',
    headers:{'Content-Type':'application/json'},
    data:newData
  })
}
//用户上传头像
export function upImg(formData) {
  return request({
    url: '/img/up',
    method: 'post',
    responseType:'json',
    headers: {'Content-Type': 'multipart/form-data'},
    data:formData
  })
}
